/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.anhndt.audiobook.ui.renderer;

import com.anhndt.audiobook.entity.ItemEntity;
import com.sun.lwuit.Component;
import com.sun.lwuit.Container;
import com.sun.lwuit.Label;
import com.sun.lwuit.List;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.list.ListCellRenderer;

/**
 *
 * @author Loki
 */
public class SettingRenderer extends Container implements ListCellRenderer {

    Label caption, value;

    public SettingRenderer() {
        super(new BorderLayout());
        setUIID("ListRenderer");
        caption = new Label();
        caption.setUIID("SettingCaption");
        value = new Label();
        value.setUIID("SettingValue");
        value.setAlignment(CENTER);
        value.getUnselectedStyle().setMargin(4, 4, 15, 15);
        //add component
        addComponent(BorderLayout.NORTH, caption);
        addComponent(BorderLayout.CENTER, value);
    }

    public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
        if (value == null || list == null) {
            return this;
        }
        setFocus(isSelected);
        this.caption.setFocus(isSelected);
        this.value.setFocus(isSelected);
        ItemEntity entity = (ItemEntity) value;
        caption.setText(entity.description);
        this.value.setText(entity.name);
        return this;
    }

    public Component getListFocusComponent(List list) {
        return null;
    }
}
